package org.yjhking.oneway;

import io.netty.util.CharsetUtil;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

/**
 * 单向消息
 *
 * @author YJH
 */
public class Producer {
    
    public static void main(String[] args) throws Exception {
        
        //1.创建生产者组
        DefaultMQProducer producer = new DefaultMQProducer("producer-hello");
        
        //2.设置NameServer地址
        producer.setNamesrvAddr("127.0.0.1:9876");
        
        //3.启动producer实例
        producer.start();
        
        //4.创建消息
        Message message = new Message("asyn-topic", "sms", "我是消息".getBytes(CharsetUtil.UTF_8));
        producer.sendOneway(message);
    }
}